package com.ugoodtech.mdcc.core.model.mapper;

import com.ugoodtech.mdcc.core.model.entity.Users;
import com.ugoodtech.mdcc.core.model.entity.UsersExample;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface UsersMapper {
    @SelectProvider(type=UsersSqlProvider.class, method="countByExample")
    int countByExample(UsersExample example);

    @DeleteProvider(type=UsersSqlProvider.class, method="deleteByExample")
    int deleteByExample(UsersExample example);

    @Delete({
        "delete from users",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into users (id, creation_time, ",
        "deleted, enabled, update_time, ",
        "account_enabled, account_expired, ",
        "account_locked, credentials_expired, ",
        "openId, password, ",
        "serviceNum, station_id, ",
        "userType, username, ",
        "role, user_flag, ",
        "union_id)",
        "values (#{id,jdbcType=BIGINT}, #{creationTime,jdbcType=TIMESTAMP}, ",
        "#{deleted,jdbcType=BIT}, #{enabled,jdbcType=BIT}, #{updateTime,jdbcType=TIMESTAMP}, ",
        "#{accountEnabled,jdbcType=BIT}, #{accountExpired,jdbcType=BIT}, ",
        "#{accountLocked,jdbcType=BIT}, #{credentialsExpired,jdbcType=BIT}, ",
        "#{openid,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, ",
        "#{servicenum,jdbcType=INTEGER}, #{stationId,jdbcType=BIGINT}, ",
        "#{usertype,jdbcType=INTEGER}, #{username,jdbcType=VARCHAR}, ",
        "#{role,jdbcType=INTEGER}, #{userFlag,jdbcType=INTEGER}, ",
        "#{unionId,jdbcType=VARCHAR})"
    })
    int insert(Users record);

    @InsertProvider(type=UsersSqlProvider.class, method="insertSelective")
    int insertSelective(Users record);

    @SelectProvider(type=UsersSqlProvider.class, method="selectByExample")
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="creation_time", property="creationTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="deleted", property="deleted", jdbcType=JdbcType.BIT),
        @Result(column="enabled", property="enabled", jdbcType=JdbcType.BIT),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="account_enabled", property="accountEnabled", jdbcType=JdbcType.BIT),
        @Result(column="account_expired", property="accountExpired", jdbcType=JdbcType.BIT),
        @Result(column="account_locked", property="accountLocked", jdbcType=JdbcType.BIT),
        @Result(column="credentials_expired", property="credentialsExpired", jdbcType=JdbcType.BIT),
        @Result(column="openId", property="openid", jdbcType=JdbcType.VARCHAR),
        @Result(column="password", property="password", jdbcType=JdbcType.VARCHAR),
        @Result(column="serviceNum", property="servicenum", jdbcType=JdbcType.INTEGER),
        @Result(column="station_id", property="stationId", jdbcType=JdbcType.BIGINT),
        @Result(column="userType", property="usertype", jdbcType=JdbcType.INTEGER),
        @Result(column="username", property="username", jdbcType=JdbcType.VARCHAR),
        @Result(column="role", property="role", jdbcType=JdbcType.INTEGER),
        @Result(column="user_flag", property="userFlag", jdbcType=JdbcType.INTEGER),
        @Result(column="union_id", property="unionId", jdbcType=JdbcType.VARCHAR)
    })
    List<Users> selectByExample(UsersExample example);

    @Select({
        "select",
        "id, creation_time, deleted, enabled, update_time, account_enabled, account_expired, ",
        "account_locked, credentials_expired, openId, password, serviceNum, station_id, ",
        "userType, username, role, user_flag, union_id",
        "from users",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @Results({
        @Result(column="id", property="id", jdbcType=JdbcType.BIGINT, id=true),
        @Result(column="creation_time", property="creationTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="deleted", property="deleted", jdbcType=JdbcType.BIT),
        @Result(column="enabled", property="enabled", jdbcType=JdbcType.BIT),
        @Result(column="update_time", property="updateTime", jdbcType=JdbcType.TIMESTAMP),
        @Result(column="account_enabled", property="accountEnabled", jdbcType=JdbcType.BIT),
        @Result(column="account_expired", property="accountExpired", jdbcType=JdbcType.BIT),
        @Result(column="account_locked", property="accountLocked", jdbcType=JdbcType.BIT),
        @Result(column="credentials_expired", property="credentialsExpired", jdbcType=JdbcType.BIT),
        @Result(column="openId", property="openid", jdbcType=JdbcType.VARCHAR),
        @Result(column="password", property="password", jdbcType=JdbcType.VARCHAR),
        @Result(column="serviceNum", property="servicenum", jdbcType=JdbcType.INTEGER),
        @Result(column="station_id", property="stationId", jdbcType=JdbcType.BIGINT),
        @Result(column="userType", property="usertype", jdbcType=JdbcType.INTEGER),
        @Result(column="username", property="username", jdbcType=JdbcType.VARCHAR),
        @Result(column="role", property="role", jdbcType=JdbcType.INTEGER),
        @Result(column="user_flag", property="userFlag", jdbcType=JdbcType.INTEGER),
        @Result(column="union_id", property="unionId", jdbcType=JdbcType.VARCHAR)
    })
    Users selectByPrimaryKey(Long id);

    @UpdateProvider(type=UsersSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Users record, @Param("example") UsersExample example);

    @UpdateProvider(type=UsersSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Users record, @Param("example") UsersExample example);

    @UpdateProvider(type=UsersSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Users record);

    @Update({
        "update users",
        "set creation_time = #{creationTime,jdbcType=TIMESTAMP},",
          "deleted = #{deleted,jdbcType=BIT},",
          "enabled = #{enabled,jdbcType=BIT},",
          "update_time = #{updateTime,jdbcType=TIMESTAMP},",
          "account_enabled = #{accountEnabled,jdbcType=BIT},",
          "account_expired = #{accountExpired,jdbcType=BIT},",
          "account_locked = #{accountLocked,jdbcType=BIT},",
          "credentials_expired = #{credentialsExpired,jdbcType=BIT},",
          "openId = #{openid,jdbcType=VARCHAR},",
          "password = #{password,jdbcType=VARCHAR},",
          "serviceNum = #{servicenum,jdbcType=INTEGER},",
          "station_id = #{stationId,jdbcType=BIGINT},",
          "userType = #{usertype,jdbcType=INTEGER},",
          "username = #{username,jdbcType=VARCHAR},",
          "role = #{role,jdbcType=INTEGER},",
          "user_flag = #{userFlag,jdbcType=INTEGER},",
          "union_id = #{unionId,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(Users record);
}